package com.xinfu.newproject.presenter;

import com.xinfu.newproject.bean.certifition.QeuryRoomBean;
import com.xinfu.newproject.bean.certifition.QeuryRoomBody;
import com.xinfu.newproject.callback.MyCallBack;
import com.xinfu.newproject.model.certifition.QeuryRoomModel;
import com.xinfu.newproject.view.IView;

import io.reactivex.disposables.Disposable;

public class QeuryRoomPresenter {
    private IView.IQueryRoomView mIQueryRoomView;

    private QeuryRoomModel mQeuryRoomModel;

    public QeuryRoomPresenter(IView.IQueryRoomView iQueryRoomView) {
        this.mIQueryRoomView = iQueryRoomView;
        mQeuryRoomModel = new QeuryRoomModel();
    }

    /**
     * 登录
     */
    public void getRoom() {

//        mIQueryRoomView.showProgress();

        QeuryRoomBody qeuryRoomBody = new QeuryRoomBody(mIQueryRoomView.header(), mIQueryRoomView.projectId());

        mQeuryRoomModel.qeuryRoom(qeuryRoomBody, new MyCallBack<QeuryRoomBean>() {
            @Override
            public void onSuccess(QeuryRoomBean qeuryRoomBean) {
//                mIQueryRoomView.hideProgress();

                if (qeuryRoomBean.isSuccess()) {
                    mIQueryRoomView.getData(qeuryRoomBean);
                } else {
                    mIQueryRoomView.showToast(qeuryRoomBean.getMessage());
                }

            }

            @Override
            public void onError(String header, String message) {
//                mIQueryRoomView.hideProgress();
                mIQueryRoomView.showToast(message);
            }

            @Override
            public void onDispose(Disposable disposable) {
                mIQueryRoomView.closeDispose(disposable);
            }
        });


    }


//    private Map<String, String> createParaMap() {
//        Map<String, String> paraMap = new HashMap<>();
//        paraMap.put("userName", mIRegisterView.getUserName());
//        return paraMap;
//    }

}
